//
//  NewsTableViewCell.m
//  10-Homework
//
//  Created by dllo on 16/7/27.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "NewsTableViewCell.h"
#import "UIView+ChangeFrame.h"
#import "CarNewsModel.h"
#import "UIImageView+WebCache.h"
@interface NewsTableViewCell ()
@property (nonatomic, strong) UIImageView *picImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation NewsTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _picImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_picImageView];
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_titleLabel];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    CGFloat leftMargin = 15;
    CGFloat topMargin = 15;
    CGFloat middleMargin = 5;
    CGFloat rightMargin = 20;
    _picImageView.frame = CGRectMake(leftMargin, topMargin, self.contentView.z_width * 0.3, self.contentView.z_height * 0.7);
    _titleLabel.frame = CGRectMake(_picImageView.z_width + _picImageView.z_x + middleMargin, topMargin + 5, self.contentView.z_width - _picImageView.z_width - _picImageView.z_x - rightMargin, self.contentView.z_height * 0.5);
}

- (void)setCarNewsModel:(CarNewsModel *)carNewsModel {
    _carNewsModel = carNewsModel;
    _titleLabel.text = carNewsModel.title;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:carNewsModel.picCover]];
    
}

@end
